#ifndef SNAKE2_H
#define SNAKE2_H

#include <QMainWindow>

namespace Ui {
class Snake2;
}

class Snake2 : public QMainWindow
{
    Q_OBJECT

public:
    explicit Snake2(QWidget *parent = 0);
    ~Snake2();
    void paintEvent(QPaintEvent *event);
    void initSnake();
    void initBoom();
    QRect CreateRect();
    void IsEat();
    void IsHit();
    void IsBoom();
    void keyPressEvent(QKeyEvent *event);
private slots:
    void Snake_update();

private:
    Ui::Snake2 *ui;
    QVector<QRect> vSnakeRect;
    QRect vSnakeHead;
    QTimer *timer;//定时器
    int Direction;//蛇的移动方向
    bool Run;//是否开始
    bool Over;//是否结束
    bool Change;//炸弹是否变化
    QRect food;
    QVector<QRect> boom;//炸弹
    int nScore;
    int speed;//移动速度
};

#endif // SNAKE2_H

